<?php $this->load->view('inc/header'); ?>

<script type="text/javascript">
$(document).ready(function(){
	//result hide init
	$('#result_ss').hide();
	
	//keywork change -> listobox enable, submit but
	$('#fields').change(function(){
		$('#search_but').removeAttr("disabled");
	})
	
	//fields change
	$('#fields').change(function(){
		var fields_var = $('#fields').val();
		
		//values 1 - organization
		if(fields_var == 1){
			//ajax call
			var url = "<?=base_url()?>search/organization_con";
			var dataSet={};
			$('#search_ds').empty().html('<img src="<?=base_url()?>images/ajax-loader.gif"/>');
			$.post(url,dataSet,function(data){
				$("#search_ds").html(data);
			 });
		}
		//values 1 - blog
		else if(fields_var == 2){
			//ajax call
			var url = "<?=base_url()?>search/blog_con";
			var dataSet={};
			$('#search_ds').empty().html('<img src="<?=base_url()?>images/ajax-loader.gif"/>');
			$.post(url,dataSet,function(data){
				$("#search_ds").html(data);
			 });
		}
	})

	//search result event click button to search
	$('#search_but').click(function(){
		var fields_var = $('#fields').val();
		
			//values 1 - organization result
			if(fields_var == 1){
				var url = "<?=base_url()?>search/search_query";
				var dataSet={keyword: $("#keyword").val(), fields: $("#fields").val(), major: $("#major").val(), date_choose: $("#date_choose").val()};
				$('#search_result_ajax').empty().html('<img src="<?=base_url()?>images/ajax-loader.gif"/>');
				$.post(url,dataSet,function(data){
					$('#result_ss').fadeIn("slow");
					$("#search_result_ajax").html(data);
				 });
			}//end if
	})
});
</script>


<!--one colunm-->
<div class="grid_12" style="background-color:#CCCCCC; padding-top:20px; padding-bottom:15px;">
<div class="grid_12 alpha" id="one_cols1">
	<div id="topic">Search</div>
</div>
<div class="grid_12 alpha"  id="one_cols2">
	
 
    <style>
		.border_form {
			border: thin solid #648F14;
			background:#EFFBD9;
		}
	</style>
    <form method="post" action="">
    <div id="search_body" style="font-size:12px; padding-left:15px;">
    <table width="70%" border="0" cellspacing="1" cellpadding="3">
    
      <tr>
        <td width="220">แสดงผลการค้นหา    ที่มีทุกคำต่อไปนี้</td>
        <td><input type="text" id="keyword" name="keyword" maxlength="100" size="60" class="border_form"></td>
      </tr>
      <tr><td>&nbsp;</td></tr>
      <tr>
        <td width="220">จากกลุ่มองค์ความรู้</td>
        <td><select name="fields" id="fields" class="border_form">
        			<option value="" disabled="disabled" selected="selected">เลือกกลุ่มองค์ความรู้</option>
            		<option value="1">Organization Node</option>
                    <option value="2">Blog Node</option>
                    <option value="1">Cops Node</option>
                </select>
       </td>
      </tr>
	</table>
   
    	<div id="search_ds">
        	
        </div>
        <div id="sub_ajax" style="margin-top:15px;">
        	<input type="button" id="search_but" value="ค้นหา" disabled="disabled">
        </div>   
    </div>
    </form>
</div>
<div class="grid_12 alpha" id="one_cols3"></div>
</div>
<div class="clear"></div>
<!--end one column-->

<!-- search result -->
<div id="result_ss">
<div class="grid_12" style="background-color:#CCCCCC; padding-bottom:15px;">
<div class="grid_12 alpha" id="one_cols1">
	<div id="topic">Search Result</div>
</div>
<div class="grid_12 alpha"  id="one_cols2">
	<div id="search_result_ajax">
    	
    </div>    
</div>
<div class="grid_12 alpha" id="one_cols3"></div>
</div>
</div>

<!-- close search result -->

<?php $this->load->view('inc/footer'); ?>